<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>值传递和引用传递</title>
  </head>

  <body>

  </body>
  <script>
    /* 
    值传递和引用传递
    */

    //1.值传递
     function test(n) {
      n = "kobe";
    }
    var name = 'why';
    test(name);
    console.log(name); //why 


    
    //2.引用传递
    function func(arr) {
      arr[0] = "jason";
    }
    var array = [1, 2, 3];
    func(array)
    console.log(array); //['jason',2,3]
  </script>


</html>